package da.metricscraft;

import java.util.HashMap;

import org.bukkit.util.Vector;


public class RegionedBiomList{
	private class RegionedBiom{
		public RegionedBiom(int regionId, String name){
			this.regionId = regionId;
			this.name = name;
		}
		public int regionId;
		public String name;
	}
	private HashMap<Integer, HashMap<Integer, RegionedBiom>> list;
	public RegionedBiomList() {
		list = new HashMap<Integer, HashMap<Integer,RegionedBiom>>();
	}
	public void addBiome(Vector location, int id, String name){
		HashMap<Integer, RegionedBiom> temp = list.get((int)location.getX());
		boolean add = false;
		if (temp == null){
			add = true;
			temp = new HashMap<Integer, RegionedBiom>();
		}
		temp.put((int)location.getZ(), new RegionedBiom(id, name));
		if (add)
			list.put((int)location.getX(), temp);
	}
	public int getId(double x, double z){
		try{
			return list.get((int)x).get((int)z).regionId;
		}catch (NullPointerException e){
			return -1;
		}
	}
	public String getName(double x, double z){
		try{
			return list.get((int)x).get((int)z).name;
		}catch (NullPointerException e){
			return "";
		}
	}
	public int getSizeX(){
		return list.size();
	}
	public int getSizeY(){
		for (HashMap<Integer, RegionedBiom> map : list.values())
			return map.size();
				return -1;
	}
}

